<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
<head>
	<title><?php echo ($title); ?></title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="keywords" content="Modern Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template,
	Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
	<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
	 <!-- Bootstrap Core CSS -->
	<link href="/Public/Dist/css/bootstrap.min.css" rel='stylesheet' type='text/css' />
	<!-- Custom CSS -->
	<link href="/Public/Admin/css/style.css" rel='stylesheet' type='text/css' />
	<!-- Graph CSS -->
	<link href="/Public/Admin/css/lines.css" rel='stylesheet' type='text/css' />
	<link href="/Public/Admin/css/font-awesome.css" rel="stylesheet">
	<!-- jQuery -->
	<script src="/Public/Dist/js/jquery.min.js"></script>
	<script src="/Public/Dist/js/bootstrap.min.js"></script>
	<!----webfonts--->
	<!--<link href='http://fonts.useso.com/css?family=Roboto:400,100,300,500,700,900' rel='stylesheet' type='text/css'>-->
	<!---//webfonts--->
	<!-- Nav CSS -->
	<link href="/Public/Admin/css/custom.css" rel="stylesheet">
	<!-- page css-->
	<link rel="stylesheet"type="text/css" href="/Public/css/page.css">
	<!-- Metis Menu Plugin JavaScript -->
	<script src="/Public/Admin/js/metisMenu.min.js"></script>
	<script src="/Public/Admin/js/custom.js"></script>
	<!-- Graph JavaScript -->
	<script src="/Public/Admin/js/d3.v3.js"></script>
	<script src="/Public/Admin/js/rickshaw.js"></script>
	<script src="/Public/js/function.js"></script>
	
    <!--<script src="/Public/js/jquery.sort.js"></script>-->
    <!--<script src="/Public/js/jquery-1.10.1.min.js"></script>-->
    <link rel="stylesheet" href="/Public/css/category.css">
    <style>
        .wareSort ul a{
            text-decoration:none;
        }
        .wareSort ul{
            width: 160px;
            height:112px;
            overflow: auto;
        }
    </style>

</head>
<body>
<div id="wrapper">
     <!-- Navigation -->
        <nav class="top1 navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="index.html">Modern</a>
            </div>
            <!-- /.navbar-header -->
            <ul class="nav navbar-nav navbar-right">
				<li class="dropdown">
	        		<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-comments-o"></i><span class="badge">4</span></a>
	        		<ul class="dropdown-menu">
						<li class="dropdown-menu-header">
							<strong>Messages</strong>
							<div class="progress thin">
							  <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
							    <span class="sr-only">40% Complete (success)</span>
							  </div>
							</div>
						</li>
						<li class="avatar">
							<a href="#">
								<img src="/Public/Admin/images/1.png" alt=""/>
								<div>New message</div>
								<small>1 minute ago</small>
								<span class="label label-info">NEW</span>
							</a>
						</li>
						<li class="avatar">
							<a href="#">
								<img src="/Public/Admin/images/2.png" alt=""/>
								<div>New message</div>
								<small>1 minute ago</small>
								<span class="label label-info">NEW</span>
							</a>
						</li>
						<li class="avatar">
							<a href="#">
								<img src="/Public/Admin/images/3.png" alt=""/>
								<div>New message</div>
								<small>1 minute ago</small>
							</a>
						</li>
						<li class="avatar">
							<a href="#">
								<img src="/Public/Admin/images/4.png" alt=""/>
								<div>New message</div>
								<small>1 minute ago</small>
							</a>
						</li>
						<li class="avatar">
							<a href="#">
								<img src="/Public/Admin/images/5.png" alt=""/>
								<div>New message</div>
								<small>1 minute ago</small>
							</a>
						</li>
						<li class="avatar">
							<a href="#">
								<img src="/Public/Admin/images/pic1.png" alt=""/>
								<div>New message</div>
								<small>1 minute ago</small>
							</a>
						</li>
						<li class="dropdown-menu-footer text-center">
							<a href="#">View all messages</a>
						</li>	
	        		</ul>
	      		</li>
			    <li class="dropdown">
	        		<a href="#" class="dropdown-toggle avatar" data-toggle="dropdown"><img src="/Public/Admin/images/1.png"><span class="badge">9</span></a>
	        		<ul class="dropdown-menu">
						<li class="dropdown-menu-header text-center">
							<strong>Account</strong>
						</li>
						<li class="m_2"><a href="#"><i class="fa fa-bell-o"></i> Updates <span class="label label-info">42</span></a></li>
						<li class="m_2"><a href="#"><i class="fa fa-envelope-o"></i> Messages <span class="label label-success">42</span></a></li>
						<li class="m_2"><a href="#"><i class="fa fa-tasks"></i> Tasks <span class="label label-danger">42</span></a></li>
						<li><a href="#"><i class="fa fa-comments"></i> Comments <span class="label label-warning">42</span></a></li>
						<li class="dropdown-menu-header text-center">
							<strong>Settings</strong>
						</li>
						<li class="m_2"><a href="#"><i class="fa fa-user"></i> Profile</a></li>
						<li class="m_2"><a href="#"><i class="fa fa-wrench"></i> Settings</a></li>
						<li class="m_2"><a href="#"><i class="fa fa-usd"></i> Payments <span class="label label-default">42</span></a></li>
						<li class="m_2"><a href="#"><i class="fa fa-file"></i> Projects <span class="label label-primary">42</span></a></li>
						<li class="divider"></li>
						<li class="m_2"><a href="#"><i class="fa fa-shield"></i> Lock Profile</a></li>
						<li class="m_2"><a href="#"><i class="fa fa-lock"></i> Logout</a></li>	
	        		</ul>
	      		</li>
			</ul>
			<form class="navbar-form navbar-right">
              <input type="text" class="form-control" value="Search..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Search...';}">
            </form>
            <!-- 左边导航栏 -->
            <div class="navbar-default sidebar" role="navigation">
                <div class="sidebar-nav navbar-collapse">
                    <ul class="nav" id="side-menu">
                        <li>
                            <a href="index.html"><i class="glyphicon glyphicon-minus"></i>Dashboard</a>
                        </li>
						<li>
							<a href="#"><i class="nav_icon glyphicon glyphicon-user"></i>用户管理<span class="glyphicon glyphicon-resize-small arrow"></span></a>
							<ul class="nav nav-second-level">
								<li>
									<a href="<?php echo U('User/index');?>">全部用户</a>
								</li>
								<li>
									<a href="<?php echo U('User/addUser');?>">新增用户</a>
								</li>
							</ul>
							<!-- /.nav-second-level -->
						</li>
						<li>
							<a href="#"><i class="nav_icon glyphicon glyphicon-user"></i>分类管理<span class="glyphicon glyphicon-resize-small arrow"></span></a>
							<ul class="nav nav-second-level">
								<li>
									<a href="<?php echo U('Category/index');?>">全部类型</a>
								</li>
								<li>
									<a href="<?php echo U('Category/addCategory');?>">新增分类</a>
								</li>
							</ul>
							<!-- /.nav-second-level -->
						</li>
                        <li>
                            <a href="#"><i class="fa fa-laptop nav_icon"></i>Layouts<span class="glyphicon glyphicon-resize-small arrow"></span></a>
                            <ul class="nav nav-second-level">
                                <li>
                                    <a href="grids.html">Grid System</a>
                                </li>
                            </ul>
                            <!-- /.nav-second-level -->
                        </li>
                        <li>
                            <a href="#"><i class="fa fa-indent nav_icon"></i>Menu Levels<span class="glyphicon glyphicon-resize-small arrow"></span></a>
                            <ul class="nav nav-second-level">
                                <li>
                                    <a href="graphs.html">Graphs</a>
                                </li>
                                <li>
                                    <a href="typography.html">Typography</a>
                                </li>
                            </ul>
                            <!-- /.nav-second-level -->
                        </li>
                        <li>
                            <a href="#"><i class="fa fa-envelope nav_icon"></i>Mailbox<span class="glyphicon glyphicon-resize-small arrow"></span></a>
                            <ul class="nav nav-second-level">
                                <li>
                                    <a href="inbox.html">Inbox</a>
                                </li>
                                <li>
                                    <a href="compose.html">Compose email</a>
                                </li>
                            </ul>
                            <!-- /.nav-second-level -->
                        </li>
                        <li>
                            <a href="widgets.html"><i class="fa fa-flask nav_icon"></i>Widgets</a>
                        </li>
                         <li>
                            <a href="#"><i class="fa fa-check-square-o nav_icon"></i>Forms<span class="glyphicon glyphicon-resize-small arrow"></span></a>
                            <ul class="nav nav-second-level">
                                <li>
                                    <a href="forms.html">Basic Forms</a>
                                </li>
                                <li>
                                    <a href="validation.html">Validation</a>
                                </li>
                            </ul>
                            <!-- /.nav-second-level -->
                        </li>
                        <li>
                            <a href="#"><i class="fa fa-table nav_icon"></i>Tables<span class="glyphicon glyphicon-resize-small arrow"></span></a>
                            <ul class="nav nav-second-level">
                                <li>
                                    <a href="basic_tables.html">Basic Tables</a>
                                </li>
                            </ul>
                            <!-- /.nav-second-level -->
                        </li>
                        <li>
                            <a href="#"><i class="fa fa-sitemap fa-fw nav_icon"></i>Css<span class="glyphicon glyphicon-resize-small arrow"></span></a>
                            <ul class="nav nav-second-level">
                                <li>
                                    <a href="media.html">Media</a>
                                </li>
                                <li>
                                    <a href="login.html">Login</a>
                                </li>
                            </ul>
                            <!-- /.nav-second-level -->
                        </li>
                    </ul>
					<script>
						$('#side-menu').children().children('a').click(function(){
							$(this).children('span').toggleClass('glyphicon glyphicon-resize-full');
							$(this).children('span').toggleClass('glyphicon glyphicon-resize-small');
						});
					</script>
                </div>
                <!-- /.sidebar-collapse -->
            </div>
            <!-- 左边导航栏结束 -->
            <!-- /.navbar-static-side -->
        </nav>
        <div id="page-wrapper">
			
    <form  id="add-form" role="form" class="form-horizontal" style="padding-top:40px;" action="<?php echo U('AddCategory');?>" method="post">
        <div class="row">
                <div class="form-group">
                    <label class="col-md-2 control-label">分类名</label>
                    <div class="col-md-8">
                        <div class="input-group input-icon right">
                                        <span class="input-group-addon">
                                            <i class="fa fa-envelope-o"></i>
                                        </span>
                            <input id="categoryname" class="form-control1" name="name" type="text" placeholder="用户名"
                                   data-toggle="popover" data-placement="right" data-content="">
                        </div>
                    </div>
                    <div class="col-sm-2">
                        <p class="help-block"></p>
                    </div>
                </div>
        </div>
        <div class="row">
            <div class="col-sm-1 col-sm-offset-1" style="text-align: right">父级类目</div>
            <div class="col-sm-8 ">
                <input type="hidden" name="pid" id="pid">
                <input type="hidden" name="path" id="path">
                <div class="wareSort clearfix">
                    <div style="float: left;" id="istop" class="btn btn-default glyphicon glyphicon-plus">
                    </div>
                    <script>
                        window.istop = 0;
                        $('#istop').click(
                                function(){
                                    $('#istop').toggleClass(' glyphicon-plus');
                                    $('#istop').toggleClass(' glyphicon-minus');
                                    if(istop%2==0){
                                        $('#istop').siblings('ul').css('display','block');
                                    }else{
                                        $('#istop').siblings('ul').css('display','none');
                                    }
                                    istop++;
                                }
                        );

                    </script>
                    <ul id="sort1" style="display: none;"></ul>
                </div>
                <!-- 获取分类js-->
                <script>
                    $(function(){
                        var sort1 = $('#sort1');
                        var sort2 = $('#sort2');
                        var sort3 = $('#sort3');
                        GetCategoryByPid();
                        function GetCategoryByPid(){
                            $.ajax({
                                type: "GET",
                                url: "<?php echo U('Category/GetCategoryByPid');?>",
                                data: "pid="+0,
                                success: function(msg){
                                    if(msg.length !== 0){
                                        areaCont = "";
                                        for (var i=0; i<msg.length; i++) {
                                            areaCont += '<li pid="'+msg[i]['id']+'" > <a href="javascript:void(0)">' + msg[i]['name'] + '</a></li>';
                                        }
                                        sort1.html(areaCont);
                                        sort1.children('li').click(function(){
                                            var lis = $(this).parent().children('li');
                                            lis.removeClass('active');
                                            lis.find('img').remove();
                                            $(this).addClass('active');
                                            $(this).children('a').append('<img src="/Public/images/arrow.png" style="float:right;">');
                                            pid =  $(this).attr('pid');

                                            $.ajax({
                                                type: "GET",
                                                url: "<?php echo U('Category/GetCategoryByPid');?>",
                                                data: "pid="+pid,
                                                success: function(msg){
                                                    $('#sort1').siblings('#sort2').remove();
                                                    $('#sort1').after('<ul id="sort2"></ul>');
                                                    areaCont = "";
                                                    for (var i=0; i<msg.length; i++) {
                                                        areaCont += '<li pid="'+msg[i]['id']+'" > <a href="javascript:void(0)">' + msg[i]['name'] + '</a></li>';
                                                    }
                                                    $('#sort2').html(areaCont);
                                                    $('#sort2').children('li').click(function(){
                                                        var lis = $(this).parent().children('li');
                                                        lis.removeClass('active');
                                                        lis.find('img').remove();
                                                        $(this).addClass('active');
                                                        $(this).children('a').append('<img src="/Public/images/arrow.png" style="float:right;">');
                                                        pid =  $(this).attr('pid');

                                                        $.ajax({
                                                            type: "GET",
                                                            url: "<?php echo U('Category/GetCategoryByPid');?>",
                                                            data: "pid="+pid,
                                                            success: function(msg){
                                                                $('#sort2').siblings('#sort3').remove();
                                                                if(msg.length != 0){
                                                                    $('#sort2').siblings('#sort3').remove();
                                                                    $('#sort2').after('<ul id="sort3"></ul>');
                                                                    initSelect($('#sort3'),msg);
                                                                    areaCont = "";
                                                                    for (var i=0; i<msg.length; i++) {
                                                                        areaCont += '<li pid="'+msg[i]['id']+'" > <a href="javascript:void(0)">' + msg[i]['name'] + '</a></li>';
                                                                    }
                                                                    $('#sort3').html(areaCont);
                                                                }else{
                                                                    $('#sort2').siblings('#sort3').remove();
                                                                }
                                                                return ;
                                                            },
                                                            error:function(msg){
                                                                popMSG('错误','获取列表失败');
                                                            }
                                                        });
                                                    });
                                                    return ;
                                                },
                                                error:function(msg){
                                                    alert(111);
                                                    console.log(msg);
                                                }
                                            });
                                        });
                                    }else{
                                        $('#sort1').siblings('#sort2').remove();
                                    }
                                    return ;
                                },
                                error:function(msg){
                                    popMSG('错误','获取列表失败');
                                }
                            });
                        }
                    });
                </script>
                <!-- 获取分类js-->
            </div>
        </div>
        <div class="row" style="margin-top:20px; ">
            <div class="col-sm-1 col-sm-offset-1" style="text-align: right">display</div>
            <div class="col-sm-8">
                <label class="radio-inline">
                    <input type="radio"  name="display" value="1"> 显示
                </label>
                <label class="radio-inline">
                    <input type="radio"  name="display" value="0"> 隐藏
                </label>
            </div>
        </div>
        <div class="row" style="margin-top:20px; ">
            <div class="col-sm-8 col-sm-offset-2">
                <input class="btn btn-info" type="submit" value="添加" >
            </div>
        </div>
    </form>
    <script>
        $(function(){
            $('#add-form').submit(function(){
                var res =checkEmpty($('#categoryname'));
                if(res){
                    popMSG('警告','分类名不能为空');
                    return false;
                }
                if(istop%2 !== 0){
                    $('#sort1').children('.active');
                    if($('#sort3').children('.active').attr('pid') !== undefined){
                        $('#pid').val($('#sort3').children('.active').attr('pid'));
                    }else if( $('#sort2').children('.active').attr('pid') !== undefined){
                        $('#pid').val($('#sort2').children('.active').attr('pid'));
                        var path = '0,'+$('#sort1').children('.active').attr('pid')+','+$('#sort2').children('.active').attr('pid')+',';
                        $('#path').val(path);
                    }else if( $('#sort1').children('.active').attr('pid') !== undefined){
                        $('#pid').val($('#sort1').children('.active').attr('pid'));
                        var path = '0,'+$('#sort1').children('.active').attr('pid')+',';
                        $('#path').val(path);
                    }else{
                        $('#path').val('0,');
                    }
                }else{
                    $('#path').val('0,');
                }
            });
        });
    </script>



			<footer>
				<?php if(!empty($popMSG)): ?><script>
						popMSG( '<?php echo $popMSG['title'] ?>','<?php echo $popMSG['msg'] ?>' );
					</script>
					<?php else: ?>
						<?php if(!empty($_GET['msgTitle'])&& !empty($_GET['msgContext'])){?>
						<script>
							popMSG( '<?php echo $_GET['msgTitle'] ?>','<?php echo $_GET['msgContext'] ?>' );
						</script>
						<?php } endif; ?>
			</footer>
        </div>
      <!-- /#page-wrapper -->
   </div>
    <!-- /#wrapper -->
    <!-- Bootstrap Core JavaScript -->
    <script src="/Public/Dist/js/bootstrap.min.js"></script>
</body>
</html>